package com.undefind;

import java.util.Random;

public class GuessNumber {
    private int numberAnswer;
    private int life;
    public GuessNumber(){
        life = 7;
    }
    public void generateNumber(){
        numberAnswer = new Random().nextInt(1,100);
    }
    public void downLife(){
        life = life --;
    }
    public boolean verifyAnswer(int userAnswer){
        if(numberAnswer > userAnswer){
            System.out.println("您输入的太小了");
            downLife();
            return false;
        }else if(numberAnswer < userAnswer){
            System.out.println("您输入的太大了");
            downLife();
            return false;
        }else{
            playerWin();
            return true;
        }
    }
    public int getLife(){
        return life;
    }
    public void playerWin(){
        System.out.println("恭喜您胜利了！");
    }
}
